#include "LinkQueue.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
struct LinkQueue
{
    DLlist list;
};


LQueue *InitLQueue()
{
    LQueue *q = (LQueue*)malloc(sizeof(LQueue));
    if(q == NULL)
        return NULL;
    
    InitDLlist(&q->list);
    return q;
}

void QPush(LQueue *q, ElementType element)
{
    InsertDLlistTail(&q->list,element);
}

void QPop(LQueue *q)
{
    RemoveByIndex(&q->list,0,NULL);
}

ElementType *GetQFront(LQueue *q)
{

    return FindByIndex(&q->list,0);
}

bool IsQueueEmpty(LQueue *q)
{
    return q->list.len == 0;
}

int GetQueueLen(LQueue *q)
{
    return q->list.len;
}

void ClearLQueue(LQueue *q, void (*clearPtr)(ElementType))
{
     ClearDLlist(&q->list,clearPtr);
}
